<?php
    #-------------------------------------------------------------#
	# This file is part of the Kumomado - Virtual Window Platform #
	# for PHP. (c) 2009 Tsai, Min Che <tirme0812@gmail.com>       #
	# Please visit http://www.kumomado.org/ for more information. #
	#                                                             #
	# This software is licensed under the GNU License v3. Please  #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#

	Kumomado::load('MVCHelper.KumomadoAbstractMVCHelper');
	Kumomado::load('Resource.Model.KumomadoAbstractResourceModel');
	Kumomado::load('Resource.Controller.KumomadoAbstractResourceController');
	Kumomado::load('Resource.View.KumomadoAbstractResourceView');
	/**
	 * @package resource
	 * @author Tsai, Min Che
	 */
	class KumomadoResource extends KumomadoAbstractMVCHelper {
		/**
		 * Construct
		 */
		public function __construct($resource_name) {
			$resource_name = ucfirst($resource_name);
			$model_name = 'KumomadoResource'.$resource_name.'Model';
			$controller_name = 'KumomadoResource'.$resource_name.'Controller';
			$view_name = 'KumomadoResource'.$resource_name.'View';
			Kumomado::load('Resource.Model.'.$model_name);
			Kumomado::load('Resource.View.'.$view_name);
			Kumomado::load('Resource.Controller.'.$controller_name);
			$this->initialize(new $controller_name(), new $model_name(), new $view_name());
		}
		/**
		 * Execute
		 */
		public function execute($method = null) {
			if (is_subclass_of($this->controller, 'KumomadoAbstractResourceController')) {
				$this->controller->external($_POST);
			}
		}
		public function get($params) {
			if (is_subclass_of($this->controller, 'KumomadoAbstractResourceController')) {
				return $this->controller->internal($params);
			}
		}
	}
?>